package com.example.backend.controller;

import com.example.backend.entity.Disease;
import com.example.backend.model.DiseaseModel;
import com.example.backend.service.DiseaseService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("disease")
public class DiseaseController {
    @Resource
    private DiseaseService diseaseService;

    @Resource
    HttpServletRequest request;

    @RequestMapping(value = "getAllDiseases", method = RequestMethod.GET)
    public DiseaseModel getAllDiseases(){
        List<Disease> diseases =diseaseService.getAllDiseases();
        if(diseases != null){
            return new DiseaseModel(0,"success",diseases);
        }
        else
            return new DiseaseModel(1,"error",null);
    }
}
